-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mellanox][pcied] Ignore bus on pcie.yaml for Mellanox switches #8063
Conversation
This pull request introduces 1 alert when merging 06ce2c37a8aea536329e32ca230b0d9271fa40db into fe6e4c3 - view on LGTM.com new alerts:
|
@sujinmkang can you please review. |
f1e2a32
to
7cb1cc2
Compare
for folder in device_folders: | ||
# For each folder in the sysfs tree we check if it matches the normal PCIe device folder pattern, | ||
# If match we add the device id from the device file and the bus from the folder name to the map | ||
pattern_for_device_folder = re.search('....:(..):..\..', folder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example for a dir name is: 0000:ff:0b.1
The name of the folder is created from: {4 digit of domain - always 0}:{2 hex digit of bus}:{2 hex digit - dev}.{fn}
You can see this pattern of the folder name also here:
https://github.com/Azure/sonic-platform-common/blob/87c81de7193ee68568543d982fb8ba38f5e4ad07/sonic_platform_base/sonic_pcie/pcie_common.py#L106
I use this regex to look for the bus (in the above example 'ff').
The dots match any character, so I am checking if the folder that starts with 4 characters (domain), colon, 2 characters of bus (they are in parentheses to create the group I am looking for), a colon, 2 characters of dev, a dot, and the fn.
I tried to create the simplest regex, but I would be glad to hear if you have a different suggestion
if pattern_for_device_folder: | ||
bus = pattern_for_device_folder.group(1) | ||
with open(os.path.join('/sys/bus/pci/devices', folder, 'device'), 'r') as device_file: | ||
device_id = device_file.read().replace('\n', '').replace('0x', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An example of the contact of a file:
0x6fe2
I am looking for the '6fe2' part only. I will add a comment regarding this, and maybe will make it simpler by changing the first replace to strip
Why I did it BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available How I did it Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id. How to verify it Verify no errors or failures in pcied on different BIOS version with the same code base.
Why I did it BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available How I did it Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id. How to verify it Verify no errors or failures in pcied on different BIOS version with the same code base.
…c-net#8063) Why I did it BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available How I did it Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id. How to verify it Verify no errors or failures in pcied on different BIOS version with the same code base.
Why I did it
BIOS upgrade on rare cases cannot guarantee bus value remain the same on every BIOS release. Ignoring this field in order for pcied not to fail but still verify device id in a different way. The solution is future proof and will not require changes in code when new BIOS version is available
How I did it
Since bus is not a fixed value (it is determined by the bios version) we are ignoring this field, and instead checking if there is a device that match on all other fields that and in addition has a matching device id.
How to verify it
Verify no errors or failures in pcied on different BIOS version with the same code base.
Which release branch to backport (provide reason below if selected)
Description for the changelog
A picture of a cute animal (not mandatory but encouraged)